/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @signatureAlgorithm = 'v2';
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('ettrafficisp', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AkDisableRequest {
  accessKeyId?: string(name='accessKeyId'),
  accessKeyName?: string(name='accessKeyName', example='akName'),
  permissions?: [ string ](name='permissions'),
}

model AkDisableResponseBody = {
  code?: string(name='code', example='200'),
  message?: string(name='message', example='The specified region of cn-zhengzhou-jva is not authorized.'),
  requestId?: string(name='requestId', example='ECF1C255-DA3D-52E5-BBE5-4F0F86793CBA'),
}

model AkDisableResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AkDisableResponseBody(name='body'),
}

async function akDisableWithOptions(request: AkDisableRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AkDisableResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.accessKeyId)) {
    body['accessKeyId'] = request.accessKeyId;
  }
  if (!Util.isUnset(request.accessKeyName)) {
    body['accessKeyName'] = request.accessKeyName;
  }
  if (!Util.isUnset(request.permissions)) {
    body['permissions'] = request.permissions;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AkDisable',
    version = '2023-08-30',
    protocol = 'HTTPS',
    pathname = `/console/ak/disable`,
    method = 'POST',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function akDisable(request: AkDisableRequest): AkDisableResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return akDisableWithOptions(request, headers, runtime);
}

model AkEnableRequest {
  accessKeyId?: string(name='accessKeyId'),
  accessKeyName?: string(name='accessKeyName', example='akName'),
  permissions?: [ string ](name='permissions'),
}

model AkEnableResponseBody = {
  code?: string(name='code', example='200'),
  message?: string(name='message', example='succeed in handling request'),
  requestId?: string(name='requestId', example='BBDB95BE-4CE7-599B-B306-4D5CBB073BF2'),
}

model AkEnableResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AkEnableResponseBody(name='body'),
}

async function akEnableWithOptions(request: AkEnableRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AkEnableResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.accessKeyId)) {
    body['accessKeyId'] = request.accessKeyId;
  }
  if (!Util.isUnset(request.accessKeyName)) {
    body['accessKeyName'] = request.accessKeyName;
  }
  if (!Util.isUnset(request.permissions)) {
    body['permissions'] = request.permissions;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AkEnable',
    version = '2023-08-30',
    protocol = 'HTTPS',
    pathname = `/console/ak/enable`,
    method = 'POST',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function akEnable(request: AkEnableRequest): AkEnableResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return akEnableWithOptions(request, headers, runtime);
}

model AkGenerateRequest {
  accessKeyName?: string(name='accessKeyName', example='AKName'),
  permissions?: [ string ](name='permissions'),
  userId?: long(name='userId', example='userId'),
}

model AkGenerateResponseBody = {
  code?: string(name='code', example='200'),
  data?: {
    accessKeyId?: string(name='accessKeyId', description='Access Key ID', example='bmqFUwnIDteQcXLoPTk4CsE3'),
    accessKeyName?: string(name='accessKeyName'),
    accessKeySecret?: string(name='accessKeySecret', example='xxxx'),
    userId?: string(name='userId'),
  }(name='data'),
  message?: string(name='message', example='noPermission'),
  requestId?: string(name='requestId', example='429FFF64-261A-5039-A375-253780D7F536'),
}

model AkGenerateResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AkGenerateResponseBody(name='body'),
}

async function akGenerateWithOptions(request: AkGenerateRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AkGenerateResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.accessKeyName)) {
    body['accessKeyName'] = request.accessKeyName;
  }
  if (!Util.isUnset(request.permissions)) {
    body['permissions'] = request.permissions;
  }
  if (!Util.isUnset(request.userId)) {
    body['userId'] = request.userId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AkGenerate',
    version = '2023-08-30',
    protocol = 'HTTPS',
    pathname = `/console/ak/generate`,
    method = 'POST',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function akGenerate(request: AkGenerateRequest): AkGenerateResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return akGenerateWithOptions(request, headers, runtime);
}

model AkListPageRequest {
  page?: int32(name='page', example='3'),
  size?: int32(name='size', example='20'),
  start?: int32(name='start', example='50'),
}

model AkListPageResponseBody = {
  code?: string(name='code', example='200'),
  data?: {
    count?: int32(name='count', example='300'),
    currentPage?: int32(name='currentPage', example='1'),
    dataList?: [ 
      {
        accessKeyId?: string(name='accessKeyId', example='LuQGonyPCRxv793AE6N0rTza'),
        accessKeyName?: string(name='accessKeyName', example='AKName'),
        accessKeySecret?: string(name='accessKeySecret', example='xxx'),
        active?: int32(name='active', example='0'),
        gmtCreate?: string(name='gmtCreate', example='2023-09-21 17:55:21'),
        gmtModify?: string(name='gmtModify', example='2023-09-21 17:55:21'),
        lastCallTime?: string(name='lastCallTime', example='2023-09-21 17:55:21'),
        permissions?: [ 
          {
            authTime?: string(name='authTime', example='2023-09-21 17:55:21'),
            description?: string(name='description'),
            group?: string(name='group', example='module'),
            permissionCode?: string(name='permissionCode', example='eta'),
            permissionName?: string(name='permissionName'),
          }
        ](name='permissions'),
      }
    ](name='dataList'),
    totalPage?: int32(name='totalPage', example='32'),
  }(name='data'),
  message?: string(name='message', example='Sorry, there have been some accidents, please contact us'),
  requestId?: string(name='requestId', example='0065DB42-1564-5805-9732-FF681A27AEAB'),
}

model AkListPageResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AkListPageResponseBody(name='body'),
}

async function akListPageWithOptions(request: AkListPageRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AkListPageResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.page)) {
    query['page'] = request.page;
  }
  if (!Util.isUnset(request.size)) {
    query['size'] = request.size;
  }
  if (!Util.isUnset(request.start)) {
    query['start'] = request.start;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AkListPage',
    version = '2023-08-30',
    protocol = 'HTTPS',
    pathname = `/console/ak/listPage`,
    method = 'GET',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function akListPage(request: AkListPageRequest): AkListPageResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return akListPageWithOptions(request, headers, runtime);
}

model AkUpdateRequest {
  accessKeyId?: string(name='accessKeyId'),
  accessKeyName?: string(name='accessKeyName', example='AKname'),
  permissions?: [ string ](name='permissions'),
}

model AkUpdateResponseBody = {
  code?: string(name='code', example='200'),
  message?: string(name='message', example='502 Bad Gateway'),
  requestId?: string(name='requestId', example='3C57ACC1-D644-5A57-9F6D-DD98F2ABFF07'),
}

model AkUpdateResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AkUpdateResponseBody(name='body'),
}

async function akUpdateWithOptions(request: AkUpdateRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AkUpdateResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.accessKeyId)) {
    body['accessKeyId'] = request.accessKeyId;
  }
  if (!Util.isUnset(request.accessKeyName)) {
    body['accessKeyName'] = request.accessKeyName;
  }
  if (!Util.isUnset(request.permissions)) {
    body['permissions'] = request.permissions;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AkUpdate',
    version = '2023-08-30',
    protocol = 'HTTPS',
    pathname = `/console/ak/update`,
    method = 'POST',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function akUpdate(request: AkUpdateRequest): AkUpdateResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return akUpdateWithOptions(request, headers, runtime);
}

model DimGroupResponseBody = {
  code?: string(name='code', example='200'),
  data?: any(name='data', example='success'),
  message?: string(name='message', example='noPermission'),
  requestId?: string(name='requestId', example='0065DB42-1564-5805-9732-FF681A27AEAB'),
}

model DimGroupResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DimGroupResponseBody(name='body'),
}

async function dimGroupWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): DimGroupResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DimGroup',
    version = '2023-08-30',
    protocol = 'HTTPS',
    pathname = `/console/dim/group`,
    method = 'GET',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function dimGroup(): DimGroupResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return dimGroupWithOptions(headers, runtime);
}

